package com.bdv.md.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table (name = "TX_TBL")
@DynamicInsert
@DynamicUpdate
public class TxTbl extends BaseObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5L;
	
	private String txId;
	private String token;
	private Integer status;
	private Integer jenisToken;
	private String balance;
	private Integer paymentMode;
	private MapTbl mapTbl;

	public TxTbl(){
	}
	
	public TxTbl(String txId, Integer status, Integer jenisToken,
			String balance, Integer paymentMode) {
		this.txId = txId;
		this.status = status;
		this.jenisToken = jenisToken;
		this.balance = balance;
		this.paymentMode = paymentMode;
	}

	
	public TxTbl(String txId, String token, Integer mapTblId) {
		this.txId = txId;
		this.token = token;
		this.mapTbl = new MapTbl(mapTblId);
	}

	@Id
	@Column(name = "TX_ID")
	public String getTxId() {
		return txId;
	}
	public void setTxId(String txId) {
		this.txId = txId;
	}
	
	@Column(name = "TOKEN")
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	
	@Column(name = "STATUS")
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	@Column(name = "JENIS_TOKEN")
	public Integer getJenisToken() {
		return jenisToken;
	}
	public void setJenisToken(Integer jenisToken) {
		this.jenisToken = jenisToken;
	}
	
	@Column(name = "BALANCE")
	public String getBalance() {
		return balance;
	}
	public void setBalance(String balance) {
		this.balance = balance;
	}
	
	@Column(name = "PAYMENT_MODE")
	public Integer getPaymentMode() {
		return paymentMode;
	}

	public void setPaymentMode(Integer paymentMode) {
		this.paymentMode = paymentMode;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MAP_ID", nullable = false)
	public MapTbl getMapTbl() {
		return mapTbl;
	}
	public void setMapTbl(MapTbl mapTbl) {
		this.mapTbl = mapTbl;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((balance == null) ? 0 : balance.hashCode());
		result = prime * result
				+ ((jenisToken == null) ? 0 : jenisToken.hashCode());
		result = prime * result + ((mapTbl == null) ? 0 : mapTbl.hashCode());
		result = prime * result
				+ ((paymentMode == null) ? 0 : paymentMode.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime * result + ((token == null) ? 0 : token.hashCode());
		result = prime * result + ((txId == null) ? 0 : txId.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TxTbl other = (TxTbl) obj;
		if (balance == null) {
			if (other.balance != null)
				return false;
		} else if (!balance.equals(other.balance))
			return false;
		if (jenisToken == null) {
			if (other.jenisToken != null)
				return false;
		} else if (!jenisToken.equals(other.jenisToken))
			return false;
		if (mapTbl == null) {
			if (other.mapTbl != null)
				return false;
		} else if (!mapTbl.equals(other.mapTbl))
			return false;
		if (paymentMode == null) {
			if (other.paymentMode != null)
				return false;
		} else if (!paymentMode.equals(other.paymentMode))
			return false;
		if (status == null) {
			if (other.status != null)
				return false;
		} else if (!status.equals(other.status))
			return false;
		if (token == null) {
			if (other.token != null)
				return false;
		} else if (!token.equals(other.token))
			return false;
		if (txId == null) {
			if (other.txId != null)
				return false;
		} else if (!txId.equals(other.txId))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "TxTbl [txId=" + txId + ", token=" + token + ", status="
				+ status + ", jenisToken=" + jenisToken + ", balance="
				+ balance + ", paymentMode=" + paymentMode + "]";
	}
	
	
}
